﻿@*
    TicketDesk - Attribution notice
    Contributor(s):

         Stephen Redd (stephen@reddnet.net, http://www.reddnet.net)

    This file is distributed under the terms of the Microsoft Public
    License (Ms-PL). See http://opensource.org/licenses/MS-PL
    for the complete terms of use.

    For any distribution that contains code from this file, this notice of
    attribution must remain intact, and a copy of the license must be
    provided to the recipient.
*@

@using PagedList.Mvc
@using TicketDesk.Domain.Model
@model TicketDesk.Web.Client.Models.TicketCenterListViewModel
@{
    var tickets = Model.Tickets;
    var ajaxSortOptions = new AjaxOptions { UpdateTargetId = "ticketList", OnBegin = "ticketCenter.sorts.beginChangeSort", OnSuccess = "ticketCenter.completeChangeList", OnFailure = "ticketCenter.completeChangeList" };
    var ajaxPagerOptions = new AjaxOptions() { HttpMethod = "GET", UpdateTargetId = "ticketList", OnBegin = "ticketCenter.paging.beginChangePage", OnSuccess = "ticketCenter.completeChangeList", OnFailure = "ticketCenter.completeChangeList" };
}
<div id="ticketList" class="panel panel-default">
    <div class="panel-heading row-no-padding">
        @Html.Partial("_FilterBar")
    </div>
    <div class="panel-body" style="padding: 0;">
        <div class="table-responsive">
            <table class="table table-hover table-condensed">
                <thead>
                    <tr>
                        <th>
                            @Ajax.SortableColumnHeader(Html, Model.CurrentListSetting, Model.CurrentPage, "SortList", Model.CurrentListSetting.ListName, "TicketId", "ID", ajaxSortOptions)
                        </th>
                        <th>
                            @Ajax.SortableColumnHeader(Html, Model.CurrentListSetting, Model.CurrentPage, "SortList", Model.CurrentListSetting.ListName, "Title", "Title", ajaxSortOptions)
                        </th>
                        <th>
                            @Ajax.SortableColumnHeader(Html, Model.CurrentListSetting, Model.CurrentPage, "SortList", Model.CurrentListSetting.ListName, "TicketStatus", "Status", ajaxSortOptions)
                        </th>
                        <th class="hidden-xs">
                            @Ajax.SortableColumnHeader(Html, Model.CurrentListSetting, Model.CurrentPage, "SortList", Model.CurrentListSetting.ListName, "Owner", "Owner", ajaxSortOptions)
                        </th>
                        <th>
                            @Ajax.SortableColumnHeader(Html, Model.CurrentListSetting, Model.CurrentPage, "SortList", Model.CurrentListSetting.ListName, "AssignedTo", "Assigned", ajaxSortOptions)
                        </th>
                        <th class="hidden-sm hidden-xs">
                            @Ajax.SortableColumnHeader(Html, Model.CurrentListSetting, Model.CurrentPage, "SortList", Model.CurrentListSetting.ListName, "TicketType", "Type", ajaxSortOptions)
                        </th>
                        <th class="hidden-sm hidden-xs">
                            @Ajax.SortableColumnHeader(Html, Model.CurrentListSetting, Model.CurrentPage, "SortList", Model.CurrentListSetting.ListName, "Category", "Category", ajaxSortOptions)
                        </th>
                        <th class="hidden-sm hidden-xs">
                            @Ajax.SortableColumnHeader(Html, Model.CurrentListSetting, Model.CurrentPage, "SortList", Model.CurrentListSetting.ListName, "Priority", "Priority", ajaxSortOptions)
                        </th>
                        <th class="hidden-sm hidden-xs">
                            @Ajax.SortableColumnHeader(Html, Model.CurrentListSetting, Model.CurrentPage, "SortList", Model.CurrentListSetting.ListName, "CreatedDate", "Created", ajaxSortOptions)
                        </th>
                        <th>
                            @Ajax.SortableColumnHeader(Html, Model.CurrentListSetting, Model.CurrentPage, "SortList", Model.CurrentListSetting.ListName, "LastUpdateDate", "Updated", ajaxSortOptions)
                        </th>
                    </tr>
                </thead>
                <tbody class="ticketItems">

                    @foreach (var item in tickets)
                    {
                        <tr class="clickable">
                            <td colspan="2" style="white-space: normal;">
                                <a href="@Url.Action("Index", "Ticket", new {area = "", id = item.TicketId})", style="margin-right: 1ex;">
                                    #@item.TicketId
                                </a>
                                @Html.DisplayFor(modelItem => item.Title)
                                @if (Model.DisplayProjects)
                                {
                                    <div>
                                        <span class="small text-muted">
                                            <i class="fa fa-book"></i>
                                            @item.Project.ProjectName
                                        </span>
                                    </div>
                                }
                            </td>
                            <td>
                                @Html.DisplayFor(modelItem => item.TicketStatus)
                            </td>
                            <td class="hidden-xs">
                                @Html.DisplayFor(modelItem => item.GetOwnerInfo().DisplayName)
                            </td>
                            <td>
                                @Html.DisplayFor(modelItem => item.GetAssignedToInfo().DisplayName)
                            </td>
                            <td class="hidden-sm hidden-xs">
                                @Html.DisplayFor(modelItem => item.TicketType)
                            </td>
                            <td class="hidden-sm hidden-xs">
                                @Html.DisplayFor(modelItem => item.Category)
                            </td>
                            <td class="hidden-sm hidden-xs">
                                @Html.DisplayFor(modelItem => item.Priority)
                            </td>
                            <td class="hidden-sm hidden-xs">
                                @item.CreatedDate.ToString("MM/dd/yyyy")<br />
                                @item.CreatedDate.ToString("hh:mm tt")
                            </td>
                            <td>
                                @item.LastUpdateDate.ToString("MM/dd/yyyy")<br />
                                @item.LastUpdateDate.ToString("hh:mm tt")
                            </td>

                        </tr>

                    }
                </tbody>

            </table>
        </div>
    </div>
    <div class="panel-footer">
        @Html.PagedListPager(Model.Tickets, page => Url.Action("PageList", new { listName = Model.CurrentListSetting.ListName, page }), PagedListRenderOptions.EnableUnobtrusiveAjaxReplacing(ajaxPagerOptions))
    </div>
</div>